package edu.xpu.cs.hub.command;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;

@RestController
@RequestMapping("/Server")
public class CommandLine {

    public void GetWorkflowDir(String name){

    }

    @GetMapping("/excute")
    public static void main(String[] args) {

        for (int i=1;i<=5;i++){
            try {
                File dir = new File("D:\\Program Files\\KNIME");//此处是指定路径D:\Program Files\KNIME
                String[] cmd = new String[] { "cmd", "/c",
                        "knime.exe -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -consoleLog -noexit -reset -workflowFile=\"G:\\knime\\workflow\\KNIME_project4.knwf\" "
                };
                // cmd[2]是要执行的dos命令
                //./kni​​me​ -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION​ -workflowDir="/root/knime-workspace/workflow/KNIME_project_1.knwf"
                //knime.exe -nosplash -application org.knime.product.KNIME_BATCH_APPLICATION -consoleLog -noexit -reset -workflowFile="G:\knime\workflow\KNIME_project4.knwf"
                System.out.println(cmd[2]);
                Process process = Runtime.getRuntime().exec(cmd,null,dir);
                process.getOutputStream().close();  // 不要忘记了一定要关

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }
}
